// pages/img/img.js
var utils = require('../../utils/util.js');
var httpUrl = getApp().globalData.httpUrl;
var codeName = getApp().globalData.codeName;
Page({

  /**
   * 页面的初始数据
   */
  data: {
  upload_picture_list:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
  
  },

  uploadpic:function(e){
    var that=this;
    var upload_picture_list = that.data.upload_picture_list;
    wx.chooseImage({
      count:8, // 默认9
      sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
      success: function (res) {
        // 返回选定照片的本地文件路径列表，tempFilePath可以作为img标签的src属性显示图片
        var tempFiles = res.tempFiles
       // console.log(tempFiles);
       //循环把图片加入到列表中
        for (var i in tempFiles){
          tempFiles[i]['upload_percent'] = 0;
          tempFiles[i]['path_server']="";
          upload_picture_list.push(tempFiles[i]);
         // console.log(that.data.upload_picture_list)
         that.setData({
           upload_picture_list: upload_picture_list
         })
        //循环把图片上传到服务器并显示进度
        for(var i in upload_picture_list){
          utils.upload_file_server(that,upload_picture_list,i);
        }
        }
      }
    })
  },

 
})